﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace HmFramework.Threading
{

	public class LockableObjectContainer<T>
	{

		internal protected T _value;
		ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();

		public LockableObjectContainer(T value)
		{
			_value = value;
		}

		public LockToken<T> GetReadToken()
		{
			return new ReadLockToken<T>(this, _lock);
		}

		public LockToken<T> GetWriteToken()
		{
			return new WriteLockToken<T>(this, _lock);
		}
	}
}
